<html>
<head>
  <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1">
  <title>Contents.m</title>
<link rel="stylesheet" type="text/css" href="../stpr.css">
</head>
<body>
<table  border=0 width="100%" cellpadding=0 cellspacing=0><tr valign="baseline">
<td valign="baseline" class="function"><b class="function">KDIST</b>
<td valign="baseline" align="right" class="function"><a href="../kernels/index.html" target="mdsdir"><img border = 0 src="../up.gif"></a></table>
  <p><b>Computes distance between vectors in kernel space.</b></p>
  <hr>
<div class='code'><code>
<span class=help></span><br>
<span class=help>&nbsp;<span class=help_field>Synopsis:</span></span><br>
<span class=help>&nbsp;&nbsp;d&nbsp;=&nbsp;kdist(X,model)</span><br>
<span class=help></span><br>
<span class=help>&nbsp;<span class=help_field>Description:</span></span><br>
<span class=help>&nbsp;&nbsp;It&nbsp;computes&nbsp;distance&nbsp;between&nbsp;vectors&nbsp;mapped&nbsp;into&nbsp;the&nbsp;feature&nbsp;</span><br>
<span class=help>&nbsp;&nbsp;space&nbsp;induced&nbsp;by&nbsp;the&nbsp;kernel&nbsp;function&nbsp;(model.options.ker,</span><br>
<span class=help>&nbsp;&nbsp;model.options.arg).&nbsp;The&nbsp;distance&nbsp;is&nbsp;computed&nbsp;between&nbsp;images</span><br>
<span class=help>&nbsp;&nbsp;of&nbsp;vectors&nbsp;X&nbsp;[dim&nbsp;x&nbsp;num_data]&nbsp;mapped&nbsp;into&nbsp;feature&nbsp;space</span><br>
<span class=help>&nbsp;&nbsp;and&nbsp;a&nbsp;point&nbsp;in&nbsp;the&nbsp;feature&nbsp;space&nbsp;given&nbsp;by&nbsp;model:</span><br>
<span class=help></span><br>
<span class=help>&nbsp;&nbsp;&nbsp;d(i)&nbsp;=&nbsp;kernel(X(:,i),X(:,i))&nbsp;</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;2*kernel(X(:,i),models.sv.X)*model.Alpha&nbsp;+&nbsp;b,</span><br>
<span class=help></span><br>
<span class=help>&nbsp;&nbsp;where&nbsp;b&nbsp;[1x1]&nbsp;is&nbsp;assumed&nbsp;to&nbsp;be&nbsp;equal&nbsp;to&nbsp;</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;model.b&nbsp;=&nbsp;model.Alpha'*kernel(model.sv.X)*model.Alpha.</span><br>
<span class=help></span><br>
<span class=help>&nbsp;<span class=help_field>Input:</span></span><br>
<span class=help>&nbsp;&nbsp;X&nbsp;[dim&nbsp;x&nbsp;num_data]&nbsp;Input&nbsp;vectors.</span><br>
<span class=help>&nbsp;&nbsp;model&nbsp;[struct]&nbsp;Deternines&nbsp;a&nbsp;point&nbsp;of&nbsp;the&nbsp;feature&nbsp;space:</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;.Alpha&nbsp;[nsv&nbsp;x&nbsp;1]&nbsp;Multipliers.</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;.sv.X&nbsp;[dim&nbsp;x&nbsp;nsv]&nbsp;Vectors.</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;.b&nbsp;[1x1]&nbsp;Bias.</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;.options.ker&nbsp;[string]&nbsp;Kernel&nbsp;identifier&nbsp;(see&nbsp;'help&nbsp;kernel').</span><br>
<span class=help>&nbsp;&nbsp;&nbsp;.options.arg&nbsp;[1&nbsp;x&nbsp;nargs]&nbsp;Kernel&nbsp;argument(s).</span><br>
<span class=help></span><br>
<span class=help>&nbsp;<span class=help_field>Output:</span></span><br>
<span class=help>&nbsp;&nbsp;d&nbsp;[num_data&nbsp;x&nbsp;1]&nbsp;Distance&nbsp;between&nbsp;vectors&nbsp;in&nbsp;the&nbsp;feature&nbsp;space.</span><br>
<span class=help></span><br>
<span class=help>&nbsp;<span class=help_field>Example:</span></span><br>
<span class=help>&nbsp;&nbsp;data&nbsp;=&nbsp;load('riply_trn');</span><br>
<span class=help>&nbsp;&nbsp;model.Alpha&nbsp;=&nbsp;dualmean(size(data.X,2));</span><br>
<span class=help>&nbsp;&nbsp;model.sv.X&nbsp;=&nbsp;data.X;</span><br>
<span class=help>&nbsp;&nbsp;model.options.ker&nbsp;=&nbsp;'rbf';</span><br>
<span class=help>&nbsp;&nbsp;model.options.arg&nbsp;=&nbsp;0.25;</span><br>
<span class=help>&nbsp;&nbsp;model.b&nbsp;=&nbsp;model.Alpha'*kernel(data.X,'rbf',0.25)*model.Alpha;</span><br>
<span class=help>&nbsp;&nbsp;[Ax,Ay]&nbsp;=&nbsp;meshgrid(linspace(-5,5,100),&nbsp;linspace(-5,5,100));</span><br>
<span class=help>&nbsp;&nbsp;dist&nbsp;=&nbsp;kdist([Ax(:)';Ay(:)'],model);</span><br>
<span class=help>&nbsp;&nbsp;figure;&nbsp;hold&nbsp;on;&nbsp;</span><br>
<span class=help>&nbsp;&nbsp;ppatterns(data.X);&nbsp;contour(&nbsp;Ax,&nbsp;Ay,&nbsp;reshape(dist,100,100));</span><br>
<span class=help>&nbsp;</span><br>
<span class=help>&nbsp;<span class=also_field>See also </span><span class=also></span><br>
<span class=help><span class=also>&nbsp;&nbsp;<a href = "../kernels/minball.html" target="mdsbody">MINBALL</a>.</span><br>
<span class=help></span><br>
</code></div>
  <hr>
  <b>Source:</b> <a href= "../kernels/list/kdist.html">kdist.m</a>
  <p><b class="info_field">About: </b>  Statistical Pattern Recognition Toolbox<br>
 (C) 1999-2003, Written by Vojtech Franc and Vaclav Hlavac<br>
 <a href="http://www.cvut.cz">Czech Technical University Prague</a><br>
 <a href="http://www.feld.cvut.cz">Faculty of Electrical Engineering</a><br>
 <a href="http://cmp.felk.cvut.cz">Center for Machine Perception</a><br>

  <p><b class="info_field">Modifications: </b> <br>
 25-aug-2004, VF, MINBALL added to See also <br>
 16-may-2004, VF<br>
 26-feb-2003, VF<br>
 13-sep-2002, VF<br>
 15-jun-2002, VF<br>

</body>
</html>
